package com.sitia.jd.service.impl;

import java.util.List;

import cn.hutool.core.util.IdUtil;
import com.sitia.common.utils.DateUtils;
import com.sitia.common.utils.SecurityUtils;
import com.sitia.common.utils.uuid.IdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.sitia.jd.mapper.CashOutOrderMapper;
import com.sitia.jd.domain.CashOutOrder;
import com.sitia.jd.service.ICashOutOrderService;

import javax.annotation.Resource;

/**
 * 提现订单Service业务层处理
 * 
 * @author sitia
 * @date 2025-06-23
 */
@Service
public class CashOutOrderServiceImpl implements ICashOutOrderService 
{
    @Resource
    private CashOutOrderMapper cashOutOrderMapper;

    /**
     * 查询提现订单
     * 
     * @param orderId 提现订单主键
     * @return 提现订单
     */
    @Override
    public CashOutOrder selectCashOutOrderByOrderId(String orderId)
    {
        return cashOutOrderMapper.selectCashOutOrderByOrderId(orderId);
    }

    /**
     * 查询提现订单列表
     * 
     * @param cashOutOrder 提现订单
     * @return 提现订单
     */
    @Override
    public List<CashOutOrder> selectCashOutOrderList(CashOutOrder cashOutOrder)
    {
        return cashOutOrderMapper.selectCashOutOrderList(cashOutOrder);
    }

    /**
     * 新增提现订单
     * 
     * @param cashOutOrder 提现订单
     * @return 结果
     */
    @Override
    public int insertCashOutOrder(CashOutOrder cashOutOrder)
    {
        cashOutOrder.setOrderId(IdUtil.getSnowflakeNextIdStr());
        cashOutOrder.setCreatedTime(DateUtils.getNowDate());
        return cashOutOrderMapper.insertCashOutOrder(cashOutOrder);
    }

    /**
     * 修改提现订单
     * 
     * @param cashOutOrder 提现订单
     * @return 结果
     */
    @Override
    public int updateCashOutOrder(CashOutOrder cashOutOrder)
    {
        cashOutOrder.setUpdatedTime(DateUtils.getNowDate());
        return cashOutOrderMapper.updateCashOutOrder(cashOutOrder);
    }

    /**
     * 批量删除提现订单
     * 
     * @param orderIds 需要删除的提现订单主键
     * @return 结果
     */
    @Override
    public int deleteCashOutOrderByOrderIds(String[] orderIds)
    {
        return cashOutOrderMapper.deleteCashOutOrderByOrderIds(orderIds);
    }

    /**
     * 删除提现订单信息
     * 
     * @param orderId 提现订单主键
     * @return 结果
     */
    @Override
    public int deleteCashOutOrderByOrderId(String orderId)
    {
        return cashOutOrderMapper.deleteCashOutOrderByOrderId(orderId);
    }

    /**
     * 添加订单（设置信息）
     * @param cashOutOrder
     * @return
     */
    @Override
    public int addCashOutOrder(CashOutOrder cashOutOrder) {
        cashOutOrder.setOwnerId(SecurityUtils.getUsername());
        cashOutOrder.setCreatedBy(SecurityUtils.getUsername());
        return this.insertCashOutOrder(cashOutOrder);
    }

    @Override
    public List<CashOutOrder> selectCashOutOrderPageList(CashOutOrder cashOutOrder) {
        return cashOutOrderMapper.selectCashOutOrderPageList(cashOutOrder);
    }
}
